package com.dizner.androidcarclient;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public class DialogUtils {

    private static final DialogUtils ourInstance = new DialogUtils();

    private static final String TAG = "DialogUtils";


    static DialogUtils getInstance() {
        return ourInstance;
    }


    private DialogUtils() {

    }

    public void showMsgDialog(Context context, String msg, final OnConfirmDialogClickListener listener) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        AlertDialog alertDialog = builder
                .setMessage(msg)
                .setNegativeButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (listener != null) {
                            listener.onOKBtnClick(dialog);
                        }
                        dialog.dismiss();
                    }
                }).setPositiveButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (listener != null) {
                            listener.onCancelBtnClick(dialog);
                        }
                        dialog.dismiss();
                    }
                }).show();
    }

    interface OnConfirmDialogClickListener {
        void onOKBtnClick(DialogInterface dialog);

        void onCancelBtnClick(DialogInterface dialog);
    }
}
